package com.macro.mall.model;

import cn.hutool.json.JSONObject;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * mbr_member_praise实体类
 *
 * @author gaodx
 *
 */
@Data
public class MbrMemberPraise implements Serializable{
	/**id*/
    @ApiModelProperty(value = "id")
	private Long id; 
	/**会员标识*/
    @ApiModelProperty(value = "会员标识")
	private Long memberId; 
	/**1-课程、2-视频、3-文章等等*/
    @ApiModelProperty(value = "1-课程、2-视频、3-文章等等")
	private Integer targetType; 
	/**如果是课程，对应的是课程id,如果是视频，对应的是视频ID*/
    @ApiModelProperty(value = "如果是课程，对应的是课程id,如果是视频，对应的是视频ID")
	private Long targetId; 
	/**评论时间*/
    @ApiModelProperty(value = "评论时间")
	private Date createTime; 
	/**
	 * 实例化
	 */
	public MbrMemberPraise() {
		super();
	}
	/**
	 * 实例化
	 * 
	 * @param obj
	 */

	public MbrMemberPraise(JSONObject obj) {
		this();
		if (obj.get("id") instanceof Number) {
			this.setId(((Number) obj.get("id")).longValue());
		}
		if (obj.get("memberId") instanceof Number) {
			this.setMemberId(((Number) obj.get("memberId")).longValue());
		}
		if (obj.get("targetType") instanceof Number) {
			this.setTargetType(((Number) obj.get("targetType")).intValue());
		}
		if (obj.get("targetId") instanceof Number) {
			this.setTargetId(((Number) obj.get("targetId")).longValue());
		}
		this.setCreateTime((Date) obj.get("createTime"));
	}
	
	/**
	 * 将当前对象转换为JsonObject
	 * 
	 * @return
	 */
	public JSONObject toJson() {
		JSONObject result = new JSONObject();
		if (this.getId() != null) {
			result.put("id",this.getId());
		}
		if (this.getMemberId() != null) {
			result.put("memberId",this.getMemberId());
		}
		if (this.getTargetType() != null) {
			result.put("targetType",this.getTargetType());
		}
		if (this.getTargetId() != null) {
			result.put("targetId",this.getTargetId());
		}
		if (this.getCreateTime() != null) {
			result.put("createTime",this.getCreateTime());
		}
		return result;
	}


	@Override
	public String toString() {
		return "MbrMemberPraise [id=" + id + " , memberId=" + memberId + " , targetType=" + targetType + " , targetId=" + targetId + " , createTime=" + createTime + "  ]";
	
	}
	
	
}
